package com.szh.common.exception;

import com.szh.common.enums.ResultCodeEnum;
import lombok.Data;

/**
 * 自定义异常类
 *
 * @author: SongZiHao
 * @date: 2023/5/10
 */
@Data
public class ServiceLibraryException extends RuntimeException {

    /**
     * 异常状态码
     */
    private Integer errorCode;

    /**
     * 异常错误信息
     */
    private String errorMsg;

    public ServiceLibraryException() {
        super();
    }

    public ServiceLibraryException(Integer errorCode, String errorMsg) {
        super(errorMsg);
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }

    public ServiceLibraryException(ResultCodeEnum resultCodeEnum) {
        super(resultCodeEnum.getMessage());
        this.errorCode = resultCodeEnum.getCode();
        this.errorMsg = resultCodeEnum.getMessage();
    }
}
